package com.dems.admin.controller;

import com.dems.admin.security.SecurityUtils;
import com.dems.dao.dataobject.ResRegion;
import com.dems.domain.JsonResponse;
import com.dems.domain.RegionReqVO;
import com.dems.service.ResRegionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/resRegion")
public class ResRegionController {
    @Autowired
    private ResRegionService resRegionService;

    @PostMapping("/find")
    public JsonResponse findResRegionPage(@RequestBody RegionReqVO regionReqVO){
        return JsonResponse.success(resRegionService.queryRegionPageInfo(regionReqVO));
    }

    @PostMapping("/create")
    public JsonResponse createResRegion(@RequestBody ResRegion resRegion){
        return JsonResponse.success(resRegionService.createRegion(resRegion, SecurityUtils.getLoanassistUser()));
    }

    @PostMapping("/update")
    public JsonResponse updateResRegion(@RequestBody ResRegion resRegion){
        return JsonResponse.success(resRegionService.updateRegion(resRegion, SecurityUtils.getLoanassistUser()));
    }
}
